﻿using MovingChame.WindowsStoreApp.Common;
using MovingChame.WindowsStoreApp.UIModule;
using MovingChameLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

namespace MovingChame.WindowsStoreApp
{
    public sealed partial class GlobalPage : LayoutAwarePage
    {
        private string query;

        public GlobalPage()
        {
            this.InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (string.IsNullOrEmpty(query))
                MainFrame.Navigate(typeof(MainPage));
            else
                MainFrame.Navigate(typeof(SearchResultsPage), query);
        }

        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            query = (string)navigationParameter;
        }

        private void HomePageButton_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(typeof(MainPage));
        }

        private void SearchTourPageButton_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(typeof(AdvancedSearchPage));
        }

        private void OfficialTourPageButton_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(typeof(OfficialTourPage));
        }

        private void PersonalTourPageButton_Click(object sender, RoutedEventArgs e)
        {
            MainFrame.Navigate(typeof(PersonalTourPage));
        }
    }
}
